package com.jdk.demo.thread.threadpool;

import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class PoolDemo {

	public static void main(String[] args) {
		ExecutorService pool = Executors.newFixedThreadPool(2);
	    Random random = new Random();

	    pool.submit(new Runnable() {
	        @Override
	        public void run() {
	            try {
	                System.out.println(Thread.currentThread().getName() + "开始执行任务");
	                Thread.sleep(random.nextInt(111));
	                System.out.println(Thread.currentThread().getName() + "执行任务完毕");
	            } catch (InterruptedException e) {
	                e.printStackTrace();
	            }
	        }
	    });
	}

}
